package SFT;
import java.util.Random;

/**Abstract class implementation of Function, as the implementation of eucNorm uses "apply" as a black box*/
public abstract class abstractFunction implements Function {	
	public double eucNorm(int startIndex, int endIndex) {
		int size=endIndex-startIndex+1;
		Complex temp;
		double sum=0;
		Random rand=new Random();
		int num=100;
		/*simply an average over randomly selected i's of: 
		 * 		|f(i)|^2*/
		for(int i=0; i<Math.min(size, num); i++){
			temp=apply(startIndex+rand.nextInt(size));
			sum+=Complex.Abs(temp)*Complex.Abs(temp);
		}
		return Math.sqrt((sum/Math.min(size,num)));
	}
	
	@Override
	public double infNorm(int i, int j){
		/*All functions we are dealing with are trivially bounded by 1, as they are WAV files*/
		return 1;
	}
}
